/*
 * Unit test for function cardEffect testing council_room card in dominion.c
 *
 * cardtest3: cardtest3.c dominion.o rngs.o
 *     gcc -o cardtest3 -g  cardtest3.c dominion.o rngs.o $(CFLAGS)
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int main() {
    int seed = 1000;
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;

    printf ("TESTING council_room card cardEffect():\n");
    memset(&G, 23, sizeof(struct gameState));   // clear the game state
    initializeGame(numPlayer, k, seed, &G); // initialize a new game

    int card = council_room;
    int choice1 = 0; //doesn't affect card
    int choice2 = 0; //doesn't affect card
    int choice3 = 0; //doesn't affect card
    int handPos = 0; //position of card in hand array, only testing one card
    int bonus = 0;

    int initialHandCount1 = G.handCount[0];
    int initialHandCount2 = G.handCount[1];
    int initialBuy = G.numBuys;
    int check = cardEffect(card, choice1, choice2, choice3, &G, handPos, &bonus);
    assert(check == 0);
    // coucil_room +4 cards, +1 buy, other player draws card;
    // check state->handCount[0], state->numBuys, state->handCount[1],
    //int afterNumBuys = G.numBuys;
    //int afterHandCount1 = G.handCount[0];
    //int afterHandCount2 = G.handCount[1];

    assert(G.handCount[0] == initialHandCount1+4-1); //add 4 cards to hand, discard council_room card from hand
    assert(G.numBuys == initialBuy+1);  // add 1 buy
    assert(G.handCount[1] == initialHandCount2+1); //add 1 card to hand of other player
    printf("All tests passed!\n");

    return 0;
}
